
<meta charset="utf-8">
<script>
    var rightname = "zhangsan";
    var rightpwd = "qwer";
    var rightcode = Math.floor(Math.random()*9000+1000);

    var inputname = prompt("请输入用户名");
    if(inputname==rightname){
        var inputpwd = prompt("请输入密码");
        if(inputpwd==rightpwd){
            var inputcode = prompt("请输入验证码："+rightcode);
            if(inputcode==rightcode){
                alert("登录成功");
            }else{
                alert("验证码错误");
            }
        }else{
            alert("您输入的密码错误");
        }
    }else{
        alert("您输入的用户名错误");
    }
</script>